import BaseResult from '../lib/BaseResult.js'
class Sign {
    static async set(ctx) {
        let data = ctx.query;
        console.log(data)
        let sign =  new Buffer(data.sign,'base64');
        ctx.session[data.token] = JSON.parse(sign.toString());
        ctx.body =`
        <script>
        localStorage.setItem('token','${data.token}');
        location.replace('/404.html');
        </script>       
        `;
    }
    static async get(ctx,next){
     //   let token = ctx.request.body.token||ctx.query.token||ctx.request.header.token;
      if(!ctx.token){ 
          ctx.body = new BaseResult(9999,null,null);
         return false;
      }
      ctx.body =new BaseResult(0,null,{
          userName:'测试'
      });
        // ctx.body =  new BaseResult(0,null,ctx.session[ctx.token]) ;
        
    }
}
export default Sign;